#pragma once

/// <summary>
/// InstanceMap: Creates a "Map" of instances around the level. 
/// <summary>

/**	Author: Dane Bulat
  * Created: 06/2013
  * Last Modified: 30/06/2013
  * Version: v1.0
  */

// Includes
#include "ModelUtil.h"
#include "common\xnacollision.h"
#include <vector>
#include <string>
using namespace std;

// Class Definition
class InstanceMap
{
public:
//==============================
// Constructors / Destructors
//==============================

  /**
    * Constructor
	*
	* @param Pointer to D3D Device.
	* @param String containing meshID.
	* @param String containing filename of instance map data.
	*/
	InstanceMap(ID3D11Device* device, const string& meshID, const string& mapFilename);

	/// Default Destructor
	~InstanceMap();
	
//==============================
// Initialisation
//==============================

  /**
    * Initialiser for instance map.
	*
	* @param Pointer to D3D Device.
	* @param String containing meshID.
	* @param String containing filename of instance map data.
	* @return Bool dependent on fail/success.
	*/
	bool Initialise(ID3D11Device* device, const string& meshID, const string& mapFilename);

//==============================
// Shutdown
//==============================

	/// Shutdown Method to delete and release member variables.
	void Shutdown();


//==============================
// Get and Set Methods
//==============================

	/// GetInstancedBuffer - Returns pointer to instanced buffer.
	ID3D11Buffer*			GetInstancedBuffer() const;			
	
	/// GetNumVisible - Returns number of visible instances after frustrum culling.
	UINT					GetNumVisible() const;

	/// SetNumVisible - Update number of visible instances after frustrum culling.
	void					SetNumVisible(UINT num);

	// GetInstancedDataP - Returns pointer to m_instancedData.
	vector<InstancedData>*	GetInstancedDataP();	

private:

	ID3D11Buffer*			m_InstancedBuffer;	///< Updated every frame to store visible instance data to send to the GPU.
	UINT					m_numVisible;		///< Updated every frame to store the amount of visible instances.
	vector<InstancedData>	m_instancedData;	///< Stores the data for each instance in the scene.
};